<template>
  <section>
    <el-row>
      <el-table :data="item.data.vals">
        <el-table-column label="脏腑" prop="name" width="100px">
        </el-table-column>
        <el-table-column v-for="(d,i) in item.reportModule.metadata.detail" :label="d.title" :key="d.code" >
          <template slot-scope="scope">
            <el-radio-group v-model="scope.row[d.code]" v-if="d.code !=='focus'">
              <el-radio label="+"></el-radio>
              <el-radio label="-"></el-radio>
              <el-radio label="±"></el-radio>
            </el-radio-group>
            <el-switch v-model="scope.row[d.code]" v-if="d.code ==='focus'">
            </el-switch>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <div>
        <el-button size="mini" type="primary" @click="savePage(item)"  v-if="item.state === 0">测试·保存</el-button>
        <el-button type="danger" size="mini" @click="delPage">删除</el-button>
        <el-button type="success" size="mini" @click="finishePage" style="float: right;margin-right: 0px"  v-if="item.state === 0">完成</el-button>
      </div>
      <div v-if="item.state === 1">
          <span style="color: red;font-weight: bold">
          报告项已创建完毕
          </span>
      </div>
    </el-row>
  </section>
</template>

<script>
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler.js'
  export default {
    name: "No3",
    props: ['item'],
    data() {
      return {
        selDetail:null,
        internalOrgans:[
          {code:'FEI',name:'肺'},
          {code:'PI',name:'脾'},
          {code:'XIN',name:'心'},
          {code:'SHEN',name:'肾'},
          {code:'XINBAO',name:'心包'},
          {code:'GAN',name:'肝'},
          {code:'DACHANG',name:'大肠'},
          {code:'WEI',name:'胃'},
          {code:'XIAOCHANG',name:'小肠'},
          {code:'PANGGUANG',name:'膀胱'},
          {code:'SANJIAO',name:'三焦'},
          {code:'DAN',name:'胆'},
        ]
      }
    },
    created(){
      console.log(this.item)
      if(this.item.data.vals){
        console.log('有val')
      }else {
        Vue.set(this.item.data,'vals',this.internalOrgans)
        console.log('没val')
      }
      console.log(this.item.data.vals)
    },
    computed:{
    },
    watch: {
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      savePage(){
        console.log(this.item.data.vals)
        this.$emit('save')
      },
      delPage(){
        this.$emit('del')
      },
      finishePage(){
        this.$emit('finish')
      }
    }
  }
</script>

<style scoped>

</style>
